#ifndef PUDGE_UI_CANVAS_HPP
#define PUDGE_UI_CANVAS_HPP

#include <vector>

namespace pudge { namespace ui {

	template<class Traits> struct canvas
	{
		typedef typename Traits::widget_type widget_type;

		widget_type * hot_;
		widget_type * hot() { return hot_; }
		void hot(widget_type * hot__) { hot_ = hot__; }

		widget_type * focus_;
		widget_type * focus() { return focus_; }
		void focus(widget_type * focus__) { focus_ = focus__; }

		widget_type * root_;
		widget_type * root() { return root_; }
		void root(widget_type * root__) { root_ = root__; }

		canvas()
			:	hot_(NULL)
			,	focus_(NULL)
			,	root_(NULL) {}

		template<class Context> void tick(Context & c)
		{
			Context::viewport_type v = c.viewport();
			Context::ui_frame_type f(v.x, v.y, v.w, v.h);
			for(widget_list::iterator i = widgets_.begin(); i != widgets_.end(); ++i)
				(**i)(c, f);
		}

		void reset()
		{
				hot_ = NULL;
				focus_ = NULL;
		}
	};
}}

#endif